package com.xiyu.service.controller.admin.material;
import com.xiyu.service.vo.material.Inventory.InventoryUpdateStatusInput;
import com.xiyu.service.vo.material.Inventory.InventorySingleGetOutput;
import com.xiyu.service.vo.material.Inventory.InventoryUpdateInput;
import com.xiyu.service.vo.material.Inventory.InventoryCreateInput;
import com.xiyu.service.vo.material.Inventory.InventoryPageQueryOutput;
import com.xiyu.service.vo.material.Inventory.InventoryPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.material.InventoryService;

@Tag(name = "盘点单管理")
@RestController
@RequestMapping("/material/inventory")
@Validated
public class InventoryController {

    @Resource
    private InventoryService InventoryService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询盘点单")
    @PreAuthorize("@ss.hasPermission('material:inventory:query')")
    public CommonResult<PageResult<InventoryPageQueryOutput>> pageQuery(@Valid InventoryPageQueryInput inputVO) {
        return success(InventoryService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增盘点单")
    @PreAuthorize("@ss.hasPermission('material:inventory:create')")
    public CommonResult<Long> create(@Valid @RequestBody InventoryCreateInput inputVO) {
        return success(InventoryService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新盘点单")
    @PreAuthorize("@ss.hasPermission('material:inventory:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody InventoryUpdateInput inputVO) {
        return success(InventoryService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个盘点单")
    @Parameter(name = "id", description = "物资盘点单主键ID", example = "")
    public CommonResult<InventorySingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(InventoryService.singleGet(id));
    }

    @PutMapping("/update-status")
    @Operation(summary = "更新")
    public CommonResult<Boolean> updateStatus(@Valid @RequestBody InventoryUpdateStatusInput inputVO) {
        return success(InventoryService.updateStatus(inputVO));
    }

}
